home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
GameContainer.as
< prev
next >
Wrap
Text File
|
2006-11-29
|
3KB
|
98 lines
class GameContainer extends SSObject
{
var classID = SSGlobal.CLSID_CONTAINER;
var collisionMask = SSGlobal.CLSID_SHAPE | SSGlobal.CLSID_MOBILEOBJECT | SSGlobal.CLSID_OBJECT;
var assetID = "Vase";
var beingCarried = false;
var editor_isItem = true;
var editor_name = "Vase";
var editor_args_names = ["contents"];
var editor_args_values = [GameContainer.prototype.contents == null ? "" : GameContainer.prototype.contents];
var editor_args_types = ["string"];
var editor_args_options = ["A-Za-z"];
var editor_args_descriptions = [""];
var editor_args_mode = [0];
var editor_args_component = ["TextInput"];
function GameContainer(contents)
{
super();
this.contents = contents;
}
function onCollision(obj)
{
if(obj.classID == SSGlobal.CLSID_VEHICLE)
{
this.shatter();
return undefined;
}
if(this.beingCarried)
{
return undefined;
}
obj.lastContainer = this;
}
function updatePosition(elapsed)
{
var _loc3_ = this.x;
var _loc2_ = this.y;
this.velocity.y += SSGlobal.GRAVITY * elapsed;
this.checkCollisions(elapsed);
this.moveBy(this.velocity.x * this.motionTime,this.velocity.y * this.motionTime,0);
if(Math.abs(_loc3_ - this.x) < 0.5 && Math.abs(_loc2_ - this.y) < 0.5)
{
this.x = _loc3_;
this.y = _loc2_;
if((this.inMotion -= elapsed) <= 0)
{
this.cancelUpdates();
this.velocity.loc(0,0,0);
}
}
}
function checkCollision(obj)
{
if(!obj.inScene)
{
return undefined;
}
var _loc3_ = undefined;
if((obj.classID & 4294901760) !== SSGlobal.CLSID_SHAPE)
{
if(SSCollision.sweepSphereToSphere(this,obj,true))
{
this.shatter(obj);
obj.immobilize();
}
}
else if(_loc3_ = SSCollision.sweepSphereToStaticShape(this,obj))
{
this.shatter();
}
}
function shatter()
{
GameSound.playSound("shatter");
if(this.contents)
{
var _loc2_ = new this.contents();
_loc2_.x = this.x;
_loc2_.y = this.y;
this.world.addObject(_loc2_);
_loc2_.addToScene();
}
this.dropParticle("vase0",this.x,this.y,this.z,this.velocity.x - 100,-200,-350,-180,4);
this.dropParticle("vase1",this.x,this.y,this.z,this.velocity.x + 100,-200,-350,180,4);
this.dropParticle("vase2",this.x,this.y,this.z,this.velocity.x - 100,-100,-200,-180,4);
this.dropParticle("vase3",this.x,this.y,this.z,this.velocity.x + 100,-100,-200,180,4);
this.world.removeObject(this);
}
function dropParticle(asset, x, y, z, vx, vy, vz, r, t)
{
var _loc2_ = new SSParticle(asset,t,new Vector(vx,vy,vz),r,SSGlobal.GRAVITY);
_loc2_.x = x;
_loc2_.y = y;
_loc2_.z = z;
this.world.addObject(_loc2_);
}
}